package com.kevin.state.machine.enums;

import lombok.Getter;

/**
 * 行为枚举
 */
@Getter
public enum Action {

    GREEN(1, "绿灯"),
    YELLOW(2, "黄灯"),
    RED(3, "红灯"),
    ;

    private final Integer id;
    private final String description;

    Action(Integer id, String description) {
        this.id = id;
        this.description = description;
    }

    public static Action valueOfId(Integer id) {
        for (Action action : Action.values()) {
            if (action.getId().equals(id)) {
                return action;
            }
        }
        throw new UnsupportedOperationException("Unsupported action !");
    }

}
